package entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author T00b!b
 */
@Entity
@Table(name = "POST")
public class Post implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name="TWEET")
    private String tweet;

    @Column(name="VISIBLE")
    private Boolean visible;

    @JoinColumn(name="PERSON")
    @ManyToOne
    private Person person;

    //Constructeurs
    public Post() {
    }

    public Post(String tweet, Boolean visible) {
        this.tweet = tweet;
        this.visible = visible;
    }
    
    public Post(Long id, String tweet, Boolean visible, Person person) {
        this.id = id;
        this.tweet = tweet;
        this.visible = visible;
        this.person = person;
    }
    
    //Accesseurs
    public Long getId() {
        return id;
    }
    
    public String getTweet() {
        return tweet;
    }

    public void setTweet(String tweet) {
        this.tweet = tweet;
    }

    public Boolean getVisible() {
        return visible;
    }

    public void setVisible(Boolean visible) {
        this.visible = visible;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Post)) {
            return false;
        }
        Post other = (Post) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Post[ id=" + id + " ]";
    }
}